#ifndef ASYNCSERVICE_H
#define ASYNCSERVICE_H

#include "core_global.h"
#include <boost/noncopyable.hpp>
#include <boost/asio/io_service.hpp>
#include <boost/function.hpp>

class AsyncService :
        protected boost::noncopyable
{
public:
    typedef boost::asio::io_service Service;

    typedef boost::function< void () > Task;

public:
    AsyncService();
    ~AsyncService();

    Service &implement();

    void post(BOOST_ASIO_MOVE_ARG(Task) task);

    void dispatch(BOOST_ASIO_MOVE_ARG(Task) task);

    void run();

    void stop();

private:
    Service m_service;
};

#endif // ASYNCSERVICE_H
